/**
 * 登录 Api
 */
import instance from '@/utils/request'

const loginPath = {
  getCodeUrl: '/getSmsCode', // 获取验证码
  loginUrl: '/login', // 登录
  changePwd: '/changePwd', // 修改密码
  noCodeLoginUrl: '/noCodeLogin', // 隐式登录
  cgCodeUrl: '/forgetPwd/getSmsCode', // 修改密码获取验证码
  cgPasswordUrl: '/forgetPwd/changePwd' // 修改密码
}

export const getCodeApi = (params: any) => {
  return instance({
    url: loginPath.getCodeUrl,
    method: 'post',
    data: {
      info: params
    }
  })
}

export const loginApi = (params: any) => {
  return instance({
    url: loginPath.loginUrl,
    method: 'post',
    headers: {
      'content-type': 'application/json'
    },
    data: {
      ...params
    }
  })
}

export const changePwdApi = (params: any) => {
  return instance({
    url: loginPath.changePwd,
    method: 'get',
    params: params
  })
}

export const noCodeLoginApi = (params: any) => {
  return instance({
    url: loginPath.noCodeLoginUrl,
    method: 'post',
    headers: {
      'content-type': 'application/json'
    },
    data: {
      ...params
    }
  })
}

export const cgCodeApi = (params: any) => {
  return instance({
    url: loginPath.cgCodeUrl,
    method: 'post',
    data: params
  })
}

export const cgPasswordApi = (params: any) => {
  return instance({
    url: loginPath.cgPasswordUrl,
    method: 'post',
    data: params
  })
}
